import java.util.*;

public class Player
{
    private int strength = 100;
    private Map<String,Thing> bag = new HashMap<>();/*？此时Map中K和V分别存放什么？注意：这种表达同名只能放一个*/
    public void showStrength(){
        System.out.println("当前体力值：" + this.strength);
    }
    
    public void step(){/*每一步发生函数*/
        this.strength -= 10;
    }
    
    public void eat(String thingName){/*？String thingName是Map<k,v>中的K吗？*/
        Thing thing = bag.get(thingName);/*c从背包里找这个物品*/
        if(thing != null){/*如果物品存在*/
            this.strength += thing.getEnergy();
            if(thing.getEnergy() < 0){
                System.out.println("你使用了：" + thing + " .");
                System.out.println("你中毒了！");
                this.showStrength();
            }else {
                System.out.println("你使用了：" );
                System.out.println("    " + thing + " .");
                System.out.println("体力增加了：" + thing.getEnergy() + " .");
                this.showStrength();
            }
            
            if(this.strength > 100){
                this.strength = 100;
                System.out.println("已到达最大体力值！");
                this.showStrength();
            }else if(this.strength <= 0){
                System.out.println("体力值耗尽！");
                System.out.println("游戏结束！");
                System.exit(0);
            }
            
            bag.remove(thingName);
        }
    }
    
    public void pick(Thing thing){
        bag.put(thing.getName(),thing);/**/
    }
    
    public void check(){
        if(bag.keySet() == null){/*存在问题！！！*/
            System.out.println("空背包。");
        }else{
            System.out.println("背包 ：");
            for(String key : bag.keySet()){
                
                System.out.println(" " + key);
            }
        }
    }
}
